// pages/shop/good/goodList.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listChange:false,
    sort:0,
    goodList: [],
    page: 1,
    pageMax:5,
    scroll: true,
    end:false,
    msg:{text:"暂无商品",img:"../../../asset/image/icon/order.png",lineHeight:"24vh"}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.ajaxMore()
    wx.setNavigationBarTitle({
      title: options.nav
    })
    this.setData({
      tid:options.tid
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  listChange:function(){
    console.log(1)
    this.setData({
      listChange:!this.data.listChange
    })
  },
  navigate:function(){
    wx.navigateTo({
      url: '../detials/detials',
    })
  },
   ajaxMore: function (e) {
    var _this = this
    var good = [{ img: '../../../asset/image/groom1.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' },
    { img: '../../../asset/image/groom2.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' },
    { img: '../../../asset/image/groom3.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' },
    { img: '../../../asset/image/groom1.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' },
    { img: '../../../asset/image/groom1.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' },
    { img: '../../../asset/image/groom2.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' },
    { img: '../../../asset/image/groom3.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' },
    { img: '../../../asset/image/groom1.jpg', goodname: '入夏套装新品', goodprice: '30.00', sellnum: '2500' }
    ]
    var goodList = this.data.goodList.concat(good);
    if(this.data.page>5){
      this.setData({
        end: true
      })
      return false;
    }
    this.setData({
      page: ++this.data.page,
      goodList: goodList,
      scroll: false
    })
    console.log(this.data.page)
    wx.showLoading({
      title: '加载中...',
      mask: true,
      success: function () {
        _this.setData({
          scroll: true
        })
        wx.hideLoading()
      }
    })

  },
  // 排序
   priceSort:function(){
     var sort = this.data.sort;
     if(sort == 0){
        sort = 1
     }else if(sort == 1){
        sort = 2
     } else if (sort == 2) {
       sort = 0
     }
     this.setData({
       sort:sort
     })
   }

})